package com.Cychat.commons.utils;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.List;

/**
 * @Author XiangWei
 * @Date 2025/10/15 14:56
 * @Description: 分页对象
 */
@Data
@Accessors(chain = true)  // 开启链式表达
@NoArgsConstructor
public class ResponsePage<T>  implements Serializable {
    private Long currentPage;           // 当前页
    private Long pageSize;              // 页大小
    private Long total;                 // 总数
    private Long totalPage;             // 总页数
    private List<T> data;               // 数据

    public ResponsePage(Page page){
        this.currentPage = page.getCurrent();
        this.pageSize = page.getSize();
        this.total = page.getTotal();
        this.totalPage = page.getPages();
        this.data = page.getRecords();
    }
}
